import { GameObjects, Scene } from 'phaser';

interface PlayGroundConfig {
  grid: { size: number; width: number; height: number };
  key: string[];
  position?: { x: number; y: number };
}

export class PlayGround {
  config: PlayGroundConfig;
  ground: GameObjects.Group;

  constructor(scene: Scene, config: PlayGroundConfig) {
    this.ground = scene.add.group();
    this.config = config;

    const { grid, key } = this.config;
    const { size, width, height } = grid;
    for (let y = 0; y < height; y++) {
      for (let x = 0; x < width; x++) {
        const img = x === 0 || x === width - 1 || y === height - 1 ? key[0] : key[1];
        this.ground.create(x * size, y * size, img).setOrigin(0);
      }
    }
  }
}
